import * as events from 'events';
interface State {
  setContext: (ctx: StateMachine<State>) => void
}
export class StateMachine<T extends State> extends events.EventEmitter {
  protected state: T;
  public transitionTo(state: T) {
    this.state = state;
    this.state.setContext(this);
  }
}